//
//  WKCommentHomeCell.m
//  WKMaybell
//
//  Created by 何文虎 on 2019/4/11.
//  Copyright © 2019 何文虎. All rights reserved.
//

#import "WKCommentHomeCell.h"

@interface WKCommentHomeCell ()
@property(nonatomic,strong)UIImageView *headerImgView;
@property(nonatomic,strong)UILabel *nameLb;
@property(nonatomic,strong)UILabel *timeLb;
@property(nonatomic,strong)UIButton *zanBtn;
@property(nonatomic,strong)UILabel *detailLb;
@end

@implementation WKCommentHomeCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self == [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self setup];
    }
    return self;
}

- (void)setup{
    
    [self.contentView addSubview:self.headerImgView];
    [self.headerImgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(12);
        make.top.mas_equalTo(15);
        make.size.mas_equalTo(CGSizeMake(36, 36));
    }];
    _headerImgView.layer.masksToBounds = YES;
    _headerImgView.layer.cornerRadius =  36/2;
    _headerImgView.backgroundColor = [UIColor cyanColor];
    
    [self.contentView addSubview:self.nameLb];
    [self.nameLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.headerImgView.mas_right).offset(12);
        make.top.mas_equalTo(self.headerImgView.mas_top);
        make.right.mas_equalTo(-12);
        make.height.mas_equalTo(14);
    }];
    
    [self.contentView addSubview:self.timeLb];
    [self.timeLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.nameLb.mas_bottom).offset(8);
        make.left.mas_equalTo(self.nameLb.mas_left);
        make.width.mas_equalTo(200);
        make.height.mas_equalTo(14);
    }];
    
    [self.contentView addSubview:self.zanBtn];
    [self.zanBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(15);
        make.right.mas_equalTo(9);
        make.width.mas_equalTo(70);
        make.height.mas_equalTo(18);
    }];
    
    [self.contentView addSubview:self.detailLb];
    _detailLb.numberOfLines = 0;
    _detailLb.preferredMaxLayoutWidth = ScreenWidth-72;
    [self.detailLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.headerImgView.mas_bottom).offset(8);
        make.left.mas_equalTo(self.nameLb.mas_left);
        make.right.mas_equalTo(-15);
        
    }];
    
    _nameLb.text = @"会飞的鱼儿";
    _timeLb.text = @"9-17 14:21";
    [_zanBtn setTitle:@"124" forState:UIControlStateNormal];
    _detailLb.text = @"《像鱼》王贰浪的这部作品，讲述的就是这样的心事，只不过这样的心事让自己感觉到多余，以至于觉得幼稚。以鱼之名比作自己，想要忘了回忆，像鱼一样只有七秒钟的记忆，像鱼一样忘了自己生活在水里。这是一首简单的歌。每个人都有所谓的心事，当试着将心事代入某首歌时，却发现自己当初是多么的幼稚。而在对方看来，这样的幼稚只是自己一个人在坚持着";
    
    
    self.hyb_lastViewInCell = self.detailLb;
    self.hyb_bottomOffsetToCell = 15;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

- (UIImageView*)headerImgView{
    if (!_headerImgView) {
        _headerImgView = [[UIImageView alloc]init];
    }
    return _headerImgView;
}

- (UILabel*)nameLb{
    if (!_nameLb) {
        _nameLb = [[UILabel alloc]init];
        _nameLb.textColor = UIColorFromHex(0x979797);
        _nameLb.font = PFSC_MediumFont(12);
    }
    return _nameLb;
}

- (UILabel*)timeLb{
    if (!_timeLb) {
        _timeLb = [[UILabel alloc]init];
        _timeLb.textColor = UIColorFromHex(0x979797);
        _timeLb.font = PFSC_MediumFont(11);
    }
    return _timeLb;
}

- (UIButton*)zanBtn{
    if (!_zanBtn) {
        _zanBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        _zanBtn.titleLabel.font = PFSC_MediumFont(11);
        [_zanBtn setTitleColor:UIColorFromHex(0x11) forState:UIControlStateNormal];
        [_zanBtn setImage:ImageNamed(@"zan_normal.png") forState:UIControlStateNormal];
        [_zanBtn setImage:ImageNamed(@"zan_selected.png") forState:UIControlStateHighlighted];
        [_zanBtn setImage:ImageNamed(@"zan_selected.png") forState:UIControlStateSelected];
    }
    return _zanBtn;
}

- (UILabel*)detailLb{
    if (!_detailLb) {
        _detailLb = [[UILabel alloc]init];
        _detailLb.textColor = UIColorFromHex(0x3C3C3C);
        _detailLb.font = PFSC_MediumFont(15);
    }
    return _detailLb;
}

@end
